import React, {useContext, useState} from 'react';

const ThemeContext = React.createContext()

const Index = props => {
    const [state, setState] = useState({name: "zhangsna", age: 16})

    return (
        <div>
            <ThemeContext.Provider value={state}>
                <Child1></Child1>
            </ThemeContext.Provider>
        </div>
    );
};

const Child1 = () => {
    const XinXi = useContext(ThemeContext);
    return (
        <div>
            {
                XinXi.name
            }--{
            XinXi.age
        }
        </div>
    )
}

Index.propTypes = {};

export default Index;
